package com.caoheng.oms.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * DataSourceConfig
 *
 * @author 水墨丹青
 * @date 2018/12/12 11:51
 */
@Configuration
public class DataSourceConfig {

    @Bean(initMethod = "init", destroyMethod = "close")
    @ConfigurationProperties(prefix = "spring.datasource")
    public DruidDataSource dataSource() {
        return DataSourceBuilder.create(DataSourceConfig.class.getClassLoader()).type(DruidDataSource.class).build();
    }
}
